import { Component, Input, Output, EventEmitter, OnInit, OnChanges } from '@angular/core';
import { ModalController, NavController } from '@ionic/angular';
import { DatePipe } from '@angular/common';
import { LeaderToPage } from '../leader-to/leader-to';

@Component({
    selector: 'pm-leader',
    templateUrl: './leader.html',
    styleUrls: ['leader.scss']
})
export class LeaderComponent implements OnInit, OnChanges {
    @Input() navs;
    options;
    nowDate;
    depart;
    @Output() navChange: EventEmitter<any> = new EventEmitter();


    constructor(public modalCtrl: ModalController, private datePipe: DatePipe, private navCtrl: NavController) {
        this.nowDate = this.datePipe.transform(new Date(), 'yyyy-MM-dd');
    }

    ngOnInit() {
        this.options = {
            bgColor: '#E8F7FF',
            elWidth: 68,
            elHeight: 68,
            levelColor: '#1fb5ff',
            lineWidth: 4,
            Num: 5
        };
        this.depart = {
            Info: [{
                department: '平台研发',
                total: 30,
                company: 15,
                out: 8,
                leave: 10,
                abnormal: 1
            },
            {
                department: '销售部',
                total: 30,
                company: 15,
                out: 8,
                leave: 10,
                abnormal: 1
            },
            {
                department: '行政部',
                total: 30,
                company: 15,
                out: 8,
                leave: 10,
                abnormal: 1
            },
            {
                department: '人事部',
                total: 30,
                company: 15,
                out: 8,
                leave: 10,
                abnormal: 1
            }]
        };
    }

    aim(i) {
    }

    toVideo() {
    }

    ngOnChanges() {
    }

    changeDate(i) {
        const addDate = new Date(this.nowDate);
        if (i === 1) {
            addDate.setDate(new Date(this.nowDate).getDate() + 1);
        } else {
            addDate.setDate(new Date(this.nowDate).getDate() - 1);
        }
        this.nowDate = this.datePipe.transform(addDate, 'yyyy-MM-dd');
        this.getInitData(this.nowDate);
    }

    getInitData(time) {
        console.log(time);
    }

    // toLeader(data) {
    //     console.log(data);
    //     this.navCtrl.push(LeaderToPage, {'title': data.department, 'departcode': data.departcode});
    // }
}
